home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PCX2TXT.ZIP / pcxtest.c < prev   
C/C++ Source or Header  |  1994-11-15  |  2KB  |  71 lines

  1. #include <dos.h>
  2. #include <conio.h>
  3.  
  4. #define WORD unsigned int
  5.  
  6. void DisplayPicture(WORD x,WORD y,char far * buffer,WORD xsize,WORD ysize);
  7.  
  8. #include "PLACE YOUR IMAGE.TXT FILENAME HERE"
  9.  
  10. void main(void)
  11. {
  12.   WORD xsize = XSIZE FROM YOUR FILE;
  13.   WORD ysize = YSIZE FROM YOUR FILE;
  14.   char far *ImageBuffer = IMAGE;
  15.  
  16.   asm {   
  17.         mov  ah, 0          // Set video mode 320x200, 256 colors
  18.         mov  al, 13h
  19.         int  10h
  20.   }
  21.        getch();
  22.        DisplayPicture(0, 0, ImageBuffer, xsize, ysize);
  23.        getch();
  24.   asm {
  25.         mov  ah, 0          // Set Text Mode 80x25 color
  26.         mov  al, 3h
  27.         int  10h
  28.   }
  29. }
  30.  
  31. // VGA 320*200, flat mode, 256 color
  32. // image blitter. Could be sped up with REP MOVSD,
  33. // but images would have to be dividable by 4 with
  34. // no remainder. REP MOVSW would need images dividable
  35. // by 2 with no remainder. This one will accept any
  36. // size image.
  37.  
  38. void DisplayPicture( unsigned int x, 
  39.                      unsigned int y, 
  40.                      char far * buffer, 
  41.                      unsigned int xsize,
  42.                      unsigned int ysize )
  43. {
  44.   asm {
  45.         push ds
  46.         mov  ax, 0a000h  // Load es with
  47.         mov  es, ax      // Video Segment
  48.         mov  bx, y
  49.         mov  ax, 320     // Start = (y*320)+x
  50.         imul bx
  51.         add  ax, x
  52.         mov  di, ax      // into destination di
  53.         mov  bx, ysize   // Read once so we keep memory
  54.                          // reads down.
  55.         mov  ax, xsize   // Same here, read once
  56.         mov  dx, 320     // added after rep movsb to
  57.                          // place us one line down in
  58.         sub  dx, xsize   // the next starting position
  59.         lds  si, buffer  // Load si:di with buffer
  60.   }
  61. drawloop:
  62.   asm {
  63.         mov  cx, ax      // Load xsize counter
  64.         rep  movsb       // copy one line
  65.         add  di, dx      // add offset for next line
  66.         dec  bx          // Have we copied enough lines?
  67.         jnz  drawloop    // Nope! Do some more then
  68.         pop  ds
  69.   }
  70. }
  71.